package io.gitee.luoyuan800.tool.llm.bean.config;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

@Data
public class AiAgentConfig {
    private ModelConfig modelConfig;
    private String system;
    private String model;
    private Double temperature = 0.3;
    private Double topP;
    private Double frequencyPenalty;
    private Double presencePenalty;
    private Double penaltyScore;
    private String responseFormat;
    private boolean stream = false;
    private Long maxToken ;
    private String stop;
    private boolean history = true;
    private Integer seed;
    private boolean webSearch;
    private boolean webSearchTrace;
    private boolean webSearchCitation;
    private boolean enableThink = true;
    private Integer thinkBudget;

    public boolean isWebSearch(){
        return webSearch || webSearchTrace || webSearchCitation;
    }

    public String getUrl() {
        if (modelConfig == null) {
            return null;
        }
        if (StringUtils.isBlank(modelConfig.getFullUrl()) && StringUtils.isNotBlank(modelConfig.getBaseUrl())) {
            modelConfig.setFullUrl(modelConfig.getBaseUrl() + "/chat/completions");
        }
        return modelConfig.getFullUrl();
    }

    public String getModel() {
        if (modelConfig == null) {
            return model;
        }
        return modelConfig.getModel();
    }

    public String getToken() {
        return modelConfig != null ? modelConfig.getToken() : null;
    }
}
